package com.baibei.module;

import android.content.Context;

import com.baibei.ebec.sdk.ApiConstant;
import com.baibei.ebec.sdk.BuildConfig;
import com.baibei.ebec.sdk.TokenInfo;
import com.baibei.model.JsInteractedInfo;
import com.baibei.sdk.SdkConfig;
import com.rae.swift.RaeSharedPreferences;
import com.rae.swift.session.SessionManager;

/**
 * js交互工厂
 * Created by shenminjie on 2017/12/13.
 * mail:shenminjie@100bei.com
 */

public class JsInteractedFactory {


    /**
     * 获取javascript交互信息
     *
     * @return return
     */
    public static JsInteractedInfo getJsInteractedInfo(Context context) {
        JsInteractedInfo info = new JsInteractedInfo();
        TokenInfo tokenInfo = SessionManager.getDefault().getUserToken();
        info.setExchange(BuildConfig.EXCHANGE);
        info.setMemberChannel(ApiConstant.MEMBER_CHANNEL);
        SdkConfig config = new RaeSharedPreferences(context.getApplicationContext()).create(SdkConfig.class);
        if (tokenInfo != null && config != null) {
            info.setAppKey(BuildConfig.APPKEY);
            info.setAppSecret(BuildConfig.APPSECRETE);
            info.setAccessToken(tokenInfo.getAccessToken());
            info.setRefreshToken(tokenInfo.getRefreshToken());
        }
        return info;
    }
}
